package com.cmy.factory;

import com.cmy.dbTransfer.DBHandler;
import com.cmy.dbTransfer.impl.MysqlDBTransferImpl;
import com.cmy.enums.DataBaseEnums;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author : Cmy
 * @date : 2025-03-20 9:01
 */
public class DataBaseTransferFactory {

    private static final Map<String, DBHandler> strategies = new ConcurrentHashMap<>();

    static{
        register(DataBaseEnums.MySQL,new MysqlDBTransferImpl());
    }

    public static DBHandler getDBTransfer(String name) {
        return strategies.get(name);
    }

    public static void register(DataBaseEnums dbEnum, DBHandler dbHandler) {
        strategies.put(dbEnum.name(), dbHandler);
    }

    public static void register(String name, DBHandler dbHandler) {
        strategies.put(name, dbHandler);
    }

}

    